package com.huifaapp.mall.activity.Homefragment.IdentActvity.IdentFrament;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * @desc
 * @auth Mr Wu Fan
 * Created by you on 2018/3/29.
 */

public class TitleFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<Fragment> fragments;
    private  List<String> stringList;

    public TitleFragmentPagerAdapter(FragmentManager fm,List<Fragment> fragments,List<String> stringList) {
        super(fm);
        this.fragments= fragments;
        this.stringList =stringList;

    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment =null;
        if (position < fragments.size()){
            fragment = fragments.get(position);
        }else {
            fragment = fragments.get(0);
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (stringList != null && stringList.size() > 0)
            return stringList.get(position);

        return null;
    }
}
